﻿@using Abp.Application.Services.Dto;
@using FwProject.Restaurant
@using FwProject.Restaurant.Dto
@using X.PagedList
@model IPagedList<DepositDto>
@{
    ViewBag.Title = "收押金";
}
@section styles{
    <link href="~/Theme/css/plugins/iCheck/custom.css" rel="stylesheet">
    <link href="~/Theme/css/plugins/datapicker/datepicker3.css" rel="stylesheet">
    <style type="text/css">
        .input-group[class*=col-] {
            padding: 0 15px;
        }
    </style>
}
}
<div class="row wrapper wrapper-content animated fadeInRight">
    <div class="col-sm-12">
        <div class="ibox float-e-margins">
            <div class="ibox-title">
                <h5>@ViewBag.Title</h5>
                <div class="ibox-tools">
                    <div class="ibox-tools">
                        @if (IsGranted(FwProject.Authorization.PermissionNames.Finance_Operation_Deposit))
                        {
                            <a href="javascript:top.window.openTab(1045,'收押金','@Url.Action("Collect")')" class="btn btn-primary btn-xs"><i class="fa fa-plus"></i>新增</a>
                        }
                        else
                        {
                            <button type="button" class="btn btn-default btn-xs">无收押金权限</button>
                        }
                        <a class="collapse-link">
                            <i class="fa fa-chevron-up"></i>
                        </a>
                        <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                            <i class="fa fa-wrench"></i>
                        </a>
                        <ul class="dropdown-menu dropdown-user">
                            <li>
                                <a href="javascript:Print()">打印</a>
                            </li>
                            <li>
                                <a href="javascript:Export()">导出</a>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
            <div class="ibox-content">
                <div class="row m-b-sm m-t-sm">
                    <form id="form" class="form-horizontal" asp-controller="Deposit" asp-action="CollectDeposit" data-ajax="true" data-ajax-update="#data_list" data-ajax-method="Get" data-ajax-mode="replace" data-ajax-begin="AjaxBegin" data-ajax-success="AjaxSuccessCallback">
                        <input type="hidden" id="size" name="size" value="0" />
                        <div class="col-lg-2 col-md-2 col-sm-2">
                            <label class="control-label col-lg-4 col-md-5 col-sm-3">状态：</label>
                            <div class="input-group">
                                <select class="input-s form-control" name="DepositStatus" id="DepositStatus">
                                    <option value=" " selected="selected">全部</option>
                                    <option value="0">未提交</option>
                                    <option value="1">已提交</option>
                                    <option value="2">已审核</option>
                                    <option value="3">退回</option>
                                </select>
                            </div>
                        </div>
                        <div class="col-lg-5 col-md-5 col-sm-5">
                            <label class="control-label col-md-2">日期：</label>
                            <div class="col-lg-2 col-md-3 col-sm-2">
                                <select id="data_select" class="input-s form-control"></select>
                            </div>
                            <div class="input-daterange input-group" id="datepicker">
                                <input type="text" name="beginTime" id="beginTime" placeholder="起始时间" class="input-sm form-control" autocomplete="off">
                                <span class="input-group-addon">至</span>
                                <input type="text" name="endTime" id="endTime" placeholder="结束时间" class="input-sm form-control" autocomplete="off" />
                            </div>
                        </div>
                        <div class="col-lg-2 col-md-2 col-sm-2">
                            <label class="control-label col-lg-4 col-md-5 col-sm-3">餐厅：</label>
                            <div class="input-group">
                                <input type="text" name="RestaurantName" id="RestaurantName" placeholder="请输入餐厅名称" class="input-sm form-control" autocomplete="off">
                            </div>
                        </div>
                        <div class="col-lg-1 col-md-1 col-sm-1">
                            <span class="input-group-btn">
                                <button type="submit" class="btn btn-sm btn-primary"> 查询</button>
                            </span>
                        </div>
                    </form>
                </div>
                <div id="data_list">
                </div>
            </div>
        </div>
    </div>
</div>


<div id="modal_ajax" class="modal inmodal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
</div>
<div id="modal_del" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content animated fadeIn">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h4 class="modal-title">删除</h4>
            </div>
            <form action="" method="post" novalidate="novalidate" data-ajax="true" data-ajax-success="DeletAjaxCallback" data-ajax-failure="FailureAjaxCallback" data-ajax-method="Post" role="form">
                @Html.AntiForgeryToken()
                <div class="modal-body">
                    <p>确定要删除？</p>
                    @*<input type="hidden" name="id" value="" />*@
                </div>
                <div class="modal-footer">
                    <button type="reset" class="btn btn-default" data-dismiss="modal">取消</button>
                    <button id="btn_del_sure" type="submit" class="btn btn-danger" data-loading-text="执行中...">确定</button>
                </div>
            </form>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>
@section scripts{
    <script src="~/Theme/js/content.min.js?v=1.0.0"></script>
    <script src="~/Theme/js/plugins/iCheck/icheck.min.js"></script>
    <script src="~/Theme/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="~/js/DateComm.js"></script>
    <script src="~/js/PrintUtil.js"></script>
    <script type="text/javascript">
               function Print() {
            printGirdObj({
                containerId: 'table_print',//包含表格容器のID
                title: '@ViewBag.Title',
                showRowNum: false,  //表格中rownumbers: true时为true
                showOrder: false,//是否显示序号，rownumbers: true时有效，默认false
                printInit: { //打印初始化设置参数
                    portrait: false //true纵向,false横向
                }
            });
        }
        function Export() {
            var RestaurantName = $('#RestaurantName').val();
            var beginTime = $('#beginTime').val();
            var endTime = $('#endTime').val();
            var DepositStatus = $("option:selected", $("#DepositStatus")).val();
            window.location.href = "/Deposit/ExportCollectDeposit?RestaurantName=" + RestaurantName + "&beginTime=" + beginTime + "&endTime=" + endTime + "&DepositStatus=" + DepositStatus;
        }

        $(document).ready(function () {
            $('#modal_ajax').on('show.bs.modal', function (e) {
                $(this).addClass('loading');
                var $button = $(e.relatedTarget);
                var url = $button.data('url');
                if (!!url) {
                    url = url + ((url.indexOf("?") > -1) ? "&r=" : "?r=") + Math.random();
                    $(this).load(url, function () {
                        $.validator.unobtrusive.parse(this); //$("#form_model_create").validate();
                        $("input[name='Member.Birthday']").datepicker({ todayBtn: "linked", keyboardNavigation: !1, forceParse: !1, calendarWeeks: !0, autoclose: !0 });
                        $(".i-checks").iCheck({ checkboxClass: "icheckbox_square-green", radioClass: "iradio_square-green", });
                        $(this).removeClass('loading');
                    });
                }
            });
            $('#modal_ajax').on('hidden.bs.modal', function (e) {
                $(this).empty();
            });

            $('#modal_del,#modal_password_reset').on('show.bs.modal', function (e) {
                var $button = $(e.relatedTarget);
                var url = $button.data('url');
                if (!!url)
                    url = url + ((url.indexOf("?") > -1) ? "&r=" : "?r=") + Math.random();
                $(this).find("form").attr("action", url);
            });
            $('#modal_del,#modal_password_reset').on('hidden.bs.modal', function (e) {
                $(this).find("form").attr("action", "");
            });

            //开始时间
            $('#beginTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var startTime = e.date;
                $('#endTime').datepicker('setStartDate', startTime);
            });
            //结束时间：
            $('#endTime').datepicker({
                todayBtn: "linked",
                autoclose: true,
                todayHighlight: true

            }).on('changeDate', function (e) {
                var endTime = e.date;
                $('#beginTime').datepicker('setEndDate', endTime);
            });

            $('#form').submit();
        });
        function ReloadAjaxCallbackgoback(data, successInfo) {
            CommonAjaxCallback(data, function () {
                $('#modal_ajax').modal("hide");

                window.location.reload();
            }, successInfo);
        }

        new DateContUtil({//【下拉日期】
            selectId: "data_select",//下拉框のID
            startDate: 'beginTime',//开始日期(不填默认search_startDateBase)
            endDate: 'endTime',//结束日期(不填默认search_endDateBase)
            defaultValue: '4',//本月
            selectedFun: function () {//选中后触发の方法
                $(".form-horizontal").submit();
            }
        });

        $("#data_list").on("change", "#pageSize", function () {
         
            var size = $("option:selected", this).val();
            $("#size").val(size);
            var pageurl = $("#pageurl").val();
            $("#form").submit();
        });
    </script>
}
